package com.gegao.chat_test;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created with IntelliJ IDEA.
 * User: Dean.Hwang
 * Date: 2016/1/14
 * Time: 11:48
 */
public class ClientTester {
    public static AtomicInteger activityThread;

    static class ChatClientThreadFactory implements ThreadFactory {
        final AtomicInteger threadNumber = new AtomicInteger(1);
        final String namePrefix = "chat-client-";
        final ChatClientGroup group;

        public ChatClientThreadFactory() {
            group = new ChatClientGroup(namePrefix + threadNumber.getAndIncrement());
        }

        @Override
        public Thread newThread(Runnable r) {

            return null;
        }
    }

    static class ChatClientGroup extends ThreadGroup {
        public ChatClientGroup(String name) {
            super(name);
        }
    }

    public static void main(String[] args) throws InterruptedException {
//        System.out.println("请输入需要运行的客户端数量");
//        Scanner scanner = new Scanner(System.in);
        AtomicInteger clientNum = new AtomicInteger(1000);
//        System.out.println("请输入发送消息间隔时间（秒）");
        int sendInterval = 2;
        activityThread = new AtomicInteger(1);


        for (int i = 1001; i <= clientNum.get()+1000; i++) {
            new WebSocketClient(i, sendInterval).run();
            System.out.println("启动了" + i + "线程");
            activityThread.incrementAndGet();
        }
        System.out.println("线程启动完成");
        while (true) {
            Thread.sleep(500);
        }

    }


}
